import axios from 'axios'

const baseURL = process.env.VUE_APP_BASE_API

// create an instance
const service = axios.create({
  baseURL,
  timeout: 10000
})

// request interceptor
service.interceptors.request.use(config => {
  return config
}, err => Promise.reject(err))

// response interceptor
service.interceptors.response.use(
  (response) => {
    const result = response.data
    // something todo:
    return Promise.resolve(result)
  },
  (error) => {
    return Promise.reject(error)
  }
)

export default service
